package 蓝桥.模拟赛;

import java.util.Arrays;

public class Main5_2 {
    // 回溯
    int min = Integer.MAX_VALUE;
    // 减掉模为23的数，且和最小

    void backtrace(int i, int[] nums, int sum) {
        if (i == nums.length) {
            if(sum%24==23 && sum<min){
                min = sum;
                System.out.println(min);
            }
            return;
        }
        backtrace(i + 1, nums, sum + nums[i]);
        backtrace(i + 1, nums, sum);


    }

    public static void main(String[] args) {

        //int[] nums = {17, 18, 33 ,37 ,45 ,57, 64, 78 ,87, 95};
        //17 18 33 37 45 57 64 78 87 95 112 132 140 153 163 166 169 187 199 216 217 250 252
        int[] nums = {17, 18, 33 ,37 ,45 ,57, 64, 78 ,87, 95, 112, 132, 140, 153, 163, 166, 169, 187, 199, 216, 217, 250, 252};

        int sum = 0;
        for (int i : nums) {
            sum += i;
        }
        System.out.println(nums.length);
        System.out.println(sum);
        System.out.println((double) sum / 24.0);

        Main5_2 m = new Main5_2();
        m.backtrace(0, nums, 0);

    }
}
